package com.data.reports.manager;


import java.util.HashMap;
import java.util.Map;

public class ConfigInvocationHandlerFactory {

    private static final Map<String,Object> configInvocationHandlerMap=new HashMap<>();

    @SuppressWarnings("unchecked")
    public static <T> T getProxy(T target){
        if (configInvocationHandlerMap.containsKey(target.getClass().getName())){
            return (T)configInvocationHandlerMap.get(target.getClass().getName());
        }
        T proxy= new ConfigInvocationHandler(target).getProxy();
        configInvocationHandlerMap.put(target.getClass().getName(),proxy);
        return proxy;
    }
}
